import cv2
import numpy as np
from time import time

img = cv2.imread('D:/python/opencv-processing/laiya.jpg')
# 取出图像的高，宽，深度 depth（通道数量）
h, w, c = img.shape
start = time()
# 一个通道的灰度图
gray = np.zeros((h, w), dtype=np.uint8)

for i in range(h):
    for j in range(w):
        gray[i, j] = max(img[i][j][0], img[i][j][1], img[i][j][2])

end = time()
print(end - start)

# 均值灰度化
cv2.imshow("gray", gray)
cv2.waitKey(0)
